﻿<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>无标题文档</title>
	<script type="text/javascript">
		if (!document.cookie.match(/blackbird=/)) {
			document.cookie = 'blackbird={pos:0,size:0,load:true};';
		}
	</script>
	<script src="blackbird.js" type="text/javascript" charset="utf-8"></script>
	<link type="text/css" rel="Stylesheet" href="blackbird.css" />
	<link type="text/css" rel="Stylesheet" href="test.css" />
	<script src="../MooTools/mootools-core.js" type="text/javascript" charset="utf-8"></script>
	<!--script src="../MooTools/mootools-more.js" type="text/javascript" charset="utf-8"></script-->
	<script type="text/javascript">
		Class.Mutators.Binds = function (binds) {
			if (!this.prototype.initialize) {
				this.implement('initialize', function () { });
			}
			return Array.from(binds).concat(this.prototype.Binds || []);
		};

		Class.Mutators.initialize = function (initialize) {
			return function () {
				Array.from(this.Binds).each(function (name) {
					var original = this[name];
					if (original) { this[name] = original.bind(this); }
				}, this);
				return initialize.apply(this, arguments);
			};
		};

		var MyClass = new Class({
			Binds: ['say'],
			initialize: function (element, message) {
				this.el = $(element);
				this.message = message;
			},
			monitor: function () {
				this.el.addEvent('click', this.say); //say is already bound to 'this'
			},
			stopMonitoring: function () {
				this.el.removeEvent('click', this.say);
			},
			say: function () {
				alert(this.message);
			}
		});

		var my = new MyClass('btnSay', 'this is a test.');
		my.monitor();

	</script>
</head>
<body>
	<div id="wrapper">
		<div id="header">
			<div class="left">
				<h1>
					<a href="#" id="btnSay">Panaghia</a></h1>
			</div>
		</div>
</body>
</html>
